Skip to content

Piecewise axis separate #3418

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 6, 2025

Conversation

MondayHopscotch
Copy link
Contributor

The existing separation logic does not correctly detect/resolve the following scenario:

  1. Object A's starting position (red dotted box) does not overlap with Object B (black box) on either the X or Y axis
  2. Object A moves to now be overlapping on BOTH axes of Object B (shown by red solid box)
    image

This is caused because the "swept hull's" look at each axis individually before updating Object A's X and Y components.

Current implementation

image

  1. Shows Object A's last (dotted red) and current (solid red) positions
  2. Shows Object A's intermediate position in Yellow
  3. Blue box shows swept hull along X-axis based on Object A's last coordinates
  4. No collision found, so Object A's intermediate x-position is updated
  5. Blue box shows swept hull along Y-axis based on Object A's last coordinates
  6. No collision found, so Object A's intermediate y-position is updated

New implementation

image

  1. Shows Object A's last (dotted red) and current (solid red) positions
  2. Shows Object A's intermediate position in Yellow
  3. Blue box shows swept hull along X-axis based on Object A's last coordinates
  4. No collision found, so Object A's intermediate x-position is updated
  • Not pictured: After this step, we temporarily update Object A's last x-position so that new swept hull captures the correct space
  1. Blue box shows swept hull along Y-axis based on Object A's newly updated last coordinates
  2. No collision found, so Object A's intermediate y-position is updated

Issue discussed in discord here

Reference material that I remembered existed when I started running into this from Leilani's island devlog

@Geokureli Geokureli added this to the 6.2.0 milestone Apr 16, 2025
@Geokureli Geokureli modified the milestones: 6.2.0, 6.1.1 Apr 28, 2025
@Geokureli Geokureli mentioned this pull request May 6, 2025
@Geokureli
Copy link
Member

Geokureli commented May 6, 2025

I was't really happy with this solution, so I tried another and that seemed even worse.

I'd really like to see a solution that doesn't need us to temporarily change instance vars to see desired behavior, but this is a really weird problem. I tried a few things, like making separateX and Y not ignore the other axis, but that caused errors when moving horizontally on a surface in platformers, I tried separating Y before X, but then I got the same issue when moving vertically against a wall.

I've outlined what I think is the optimal solution, here, but for now, I think we should implement this solution

Thanks!

@Geokureli Geokureli merged commit f5fc836 into HaxeFlixel:dev May 6, 2025
19 of 21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants